package cn.iocoder.yudao.module.product.api.packaging;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.product.api.packaging.dto.PackagingDTO;
import cn.iocoder.yudao.module.product.dal.dataobject.packaging.PackagingDO;
import cn.iocoder.yudao.module.product.dal.mysql.packaging.PackagingMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PackagingMapperApiImpl implements PackagingMapperApi{

    @Resource
    private PackagingMapper packagingMapper;

    @Override
    public PackagingDTO selectByPackagingDto(Long skuId) {
        LambdaQueryWrapperX<PackagingDO> wrapperX = new LambdaQueryWrapperX<>();
        wrapperX.eq(PackagingDO :: getSkuId, skuId);
        PackagingDO packagingDO = packagingMapper.selectOne(wrapperX);
        return BeanUtils.toBean(packagingDO, PackagingDTO.class);
    }
}
